#operate file

#write
f=open("file.txt", "w", 1024, "UTF-8")
f.write('this is a line test content')
f.close()

#read and split
#split默认根据\n分割
f = open("hello.txt","w",1024,"UTF-8")
f.write('Hello\nWorld')
f = open("hello.txt","r",1024,"UTF-8")
text = f.read();
print(text)
print(text.split())

test_array = "1;2;3;4|5";
print(test_array.split())

str='1\n2\n3'
print(str)
# #空格分割
# str1='1 2 3'
# print(str1)

#sep是分割的标志，maxsplit表示最大分割成几个元素
#不指定maxsplit表示根据标志符号进行分割
str='1,2,3'
print(str.split(sep=','))
print(str.split(sep=',', maxsplit=0))
print(str.split(sep=',', maxsplit=1))

